import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_wan_android/application.dart';
import 'package:fluro/fluro.dart';
import 'package:flutter_wan_android/res/theme.dart';
import 'package:flutter_wan_android/routes/routes.dart';
import 'package:provider/provider.dart';

void main() {
  // 注册 fluro routes
  FluroRouter router = FluroRouter();
  Routes.configureRoutes(router);
  Application.router = router;

  var a = MyTest(12.34, 100);
  print(a.toString());

  runApp(MyApp());

  if (Platform.isAndroid) {
    // 以下两行 设置android状态栏为透明的沉浸。写在组件渲染之后，是为了在渲染后进行set赋值，覆盖状态栏，写在渲染之前MaterialApp组件会覆盖掉这个值。
    SystemUiOverlayStyle systemUiOverlayStyle =
        SystemUiOverlayStyle(statusBarColor: Colors.transparent);
    SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
  }
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MultiProvider(
      providers: [
        ChangeNotifierProvider(create: (_) => WTheme()),
      ],
      child: MaterialApp(
        title: 'Welcome to Flutter',
        navigatorKey: Application.navGK,
        onGenerateRoute: Application.router.generator,
        builder: EasyLoading.init(),
      ),
    );
  }
}

class MyTest {
  double price;
  int count;

  String name;

  String other;

  MyTest(this.price, this.count)
      : name = "1232",
        other = "没毛病";

  @override
  String toString() {
    return 'MyTest{price: $price, count: $count, name: $name, other: $other}';
  }
}
